﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DatabaseHelper
{
    /// <summary>
    /// PData class present a row with main fields in Data table
    /// </summary>
    public class PData
    {
        #region PROPERTIES
        /// <summary>
        /// Logged time
        /// </summary>
        public DateTime DataTime { get; set; }
        /// <summary>
        /// Kilometer post of data at logged time
        /// </summary>
        public string KP { get; set; }
        /// <summary>
        /// Easting (~longitude) in local coordinate system of data at logged time
        /// </summary>
        public string Easting { get; set; }
        /// <summary>
        /// Northing (~latitude) in local coordinate system of data at logged time
        /// </summary>
        public string Northing { get; set; }
        /// <summary>
        /// Cathodic protection reading value (in V or mV) of data at logged time
        /// </summary>
        public string CP { get; set; }
        #endregion

        #region CONSTRUCTORS
        /// <summary>
        /// Default constructor
        /// <remarks>DataTime is assigned to DateTime.Now</remarks>
        /// </summary>
        public PData()
        {
            DataTime = DateTime.Now;
            KP = "";
            Easting = "";
            Northing = "";
            CP = "";
        }

        /// <summary>
        /// Constructor with KP, Easting, Northing and CP
        /// </summary>
        /// <param name="kp">KP</param>
        /// <param name="east">Easting</param>
        /// <param name="north">Northing</param>
        /// <param name="cp">CP</param>
        public PData(string kp, string east, string north, string cp)
            : this()
        {
            KP = kp;
            Easting = east;
            Northing = north;
            CP = cp;
        }
        #endregion

        #region METHODS
        /// <summary>
        /// Display data info in a message box
        /// </summary>
        public void Disp()
        {
            MessageBox.Show(
                DataTime.ToString() + "\n" +
                KP + "\n" +
                Easting + "\n" +
                Northing + "\n" +
                CP + "\n" 
                );
        }
        /// <summary>
        /// Convert to PEvent 
        /// </summary>
        /// <returns>PEvent class object</returns>
        public PEvent ToPEvent()
        {
            PEvent pe = new PEvent();
            pe.KP = KP;
            pe.Easting = Easting;
            pe.Northing = Northing;

            return pe;
        }
        #endregion
    }
}
